<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
        <script>
            function fn(num){
                var a,b,c,d;
                a=parseInt(num%1000);
                a%=10;                
                b=parseInt(num%100);
                b%=10;
                c=parseInt(num%10);
                c%=10;
                d=num%10;
                a+=5;b+=5;c+=5;d+=5;
                a%=10;b%=10;c%=10;d=num%10;
                var flag;
                flag=a;
                a=d;
                d=flag;
                flag=b;
                b=c;
                c=flag;
                console.log(a+''+b+c+d);
            }
            fn(2345);
        </script>
</body>
</html>